package tests;

import common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class EditPage extends Utils {

    public static String url = "http://8.137.19.140:9090/blog_edit.html";

    public EditPage() {

        super(url);

    }
    public void EditSuc(){

        driver.findElement(By.cssSelector("#submit"));
        driver.findElement(By.cssSelector("#title")).sendKeys("测试标题12");
        driver.findElement(By.cssSelector("#submit")).click();

        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(6) > div.title"));
        //设置显示等待
        WebDriverWait wait1 = new WebDriverWait(driver, 2);
        //通过url检查是否跳转页面
        wait1.until(ExpectedConditions.urlToBe("http://8.137.19.140:9090/blog_list.html"));

        // 如果 URL 跳转成功，打印成功信息
       System.out.println("页面跳转成功，当前 URL: " + driver.getCurrentUrl());
    }
    public void EditSuc1(){
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(6)")).click();
        driver.findElement(By.cssSelector("body > div.container-login > div > h3"));
        driver.findElement(By.cssSelector("#submit"));
        System.out.println("恭喜你，离成功有近了一步，加油");
    }
}
